package com.yaorange.module.association.controller;

import com.yaorange.module.association.dto.BsNewsDto;
import com.yaorange.module.association.service.BsNewsService;
import com.yaorange.pojo.BsNews;
import com.yaorange.response.PageResult;
import com.yaorange.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bsNews")
@Slf4j
public class BsNewsController {
    @Autowired
    BsNewsService bsNewsService;
    @GetMapping("/page")
    public Result<PageResult<BsNews>> selectPage(
            BsNewsDto bsNewsDto
    ) {
        log.info("查询新闻数据{}",bsNewsDto);
        PageResult<BsNews> pageResult = bsNewsService.selectPage(bsNewsDto);
        return Result.success(pageResult);
    }
    @PutMapping
    public Result update(@RequestBody BsNews bsNews) {
        log.info("修改新闻数据{}",bsNews);
        bsNewsService.update(bsNews);
        return Result.success();
    }
    @PostMapping
    public Result add(@RequestBody BsNews bsNews) {
        log.info("添加新闻数据{}",bsNews);
        bsNewsService.add(bsNews);
        return Result.success();
    }
}
